package singleton;

/**
 * 双检锁
 * 优点：懒加载，线程安全，效率高。
 * 缺点：写法较复杂。
 * Created by thiswhyme on 2019/03/15.
 */
public class DclSingleton {

    private volatile static DclSingleton instance;

    private DclSingleton() {

    }

    public static DclSingleton getInstance() {
        if (null == instance) {
            synchronized (DclSingleton.class) {
                if (null == instance) {
                    instance = new DclSingleton();
                }
            }
        }
        return instance;
    }
}
